

/**
 * Translational limits and motor settings of a joint.
 */
export class TranslationalLimitMotor {
	/**
	 * The lower bound of the limit in usually meters.
	 *
	 * The limit is disabled if `lowerLimit > upperLimit`.
	 */
	 lowerLimit:number;

	/**
	 * The upper bound of the limit in usually meters.
	 *
	 * The limit is disabled if `lowerLimit > upperLimit`.
	 */
	 upperLimit:number;

	/**
	 * The target speed of the motor in usually meters per second.
	 */
	 motorSpeed:number;

	/**
	 * The maximum force of the motor in usually newtons.
	 *
	 * The motor is disabled if `motorForce <= 0`.
	 */
	 motorForce:number;

	/**
	 * Default constructor.
	 */
	constructor() {
		this.lowerLimit = 1;
		this.upperLimit = 0;
		this.motorForce = 0;
	}

	/**
	 * Sets limit properties at once and returns `this`.
	 * `this.lowerLimit` is set to `lower`, and `this.upperLimit` is set to `upper`.
	 */
	public setLimits(lower:number, upper:number):TranslationalLimitMotor {
		this.lowerLimit = lower;
		this.upperLimit = upper;
		return this;
	}

	/**
	 * Sets motor properties at once and returns `this`.
	 * `this.motorSpeed` is set to `speed`, and `this.motorForce` is set to `force`.
	 */
	public setMotor(speed:number, force:number):TranslationalLimitMotor {
		this.motorSpeed = speed;
		this.motorForce = force;
		return this;
	}

	/**
	 * Returns a clone of the object.
	 */
	public clone():TranslationalLimitMotor {
		var lm:TranslationalLimitMotor = new TranslationalLimitMotor();
		lm.lowerLimit = this.lowerLimit;
		lm.upperLimit = this.upperLimit;
		lm.motorSpeed = this.motorSpeed;
		lm.motorForce = this.motorForce;
		return lm;
	}
}
